package com.flight.trans.adapter;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flight.trans.R;
import com.flight.trans.base.BaseRecyclerAdapter;
import com.flight.trans.base.BaseViewHolder;
import com.flight.trans.bean.MessageBean.MessageData;

import java.util.List;

/**
 * 消息列表
 */
public class MessageAdapter extends BaseRecyclerAdapter<MessageData> {

    public MessageAdapter(Context mContext, List<MessageData> mList) {
        super(mContext, mList);
    }

    @Override
    public int setContentView() {
        return R.layout.adapter_message;
    }

    @Override
    protected void bindData(BaseViewHolder holder, MessageData data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);

        TextView mTvMessageTitle = holder.findViewById(R.id.mTvMessageTitle);
        TextView mTvMessageSender = holder.findViewById(R.id.mTvMessageSender);
        TextView mTvMessageTime = holder.findViewById(R.id.mTvMessageTime);

        mTvMessageTitle.setText(data.getTitle());
        mTvMessageSender.setText(data.getSender());
        mTvMessageTime.setText(data.getTime());

        mTvMessageTitle.setTextColor(mContext.getColor(data.isSelected() ? R.color.white : R.color.black));
        mTvMessageSender.setTextColor(mContext.getColor(data.isSelected() ? R.color.white : R.color.black));
        mTvMessageTime.setTextColor(mContext.getColor(data.isSelected() ? R.color.white : R.color.black));
        mLlContainerItem.setBackgroundColor(mContext.getColor(data.isSelected() ? R.color.color_blue_dark : R.color.white));

        setOnItemClickListener(mLlContainerItem , position);
    }
}
